package parser.news;

import services.ChannelService;

import javax.ejb.EJB;

/**
 * Parser for getting news from Habrahabr channel
 * User: kaiser
 * Date: 7/31/13
 * Time: 9:32 PM
 */
public class HabrParser extends ChannelParser {

    @EJB
    ChannelService channelService;
    /**
     * Channel identifier name
     */
    public static final String CHANNEL_ID = "habrahabr";

    /**
     * Habrahbr RSS URL resource
     */
    protected final String RESOURCE = "http://habrahabr.ru/rss/best/";

    @Override
    protected NewsHandler getParserHandler() {
        return new NewsHandler() {

            @Override
            String getNewsTitleTag() {
                return "title";
            }

            @Override
            String getNewsUrlTag() {
                return "link";
            }

            @Override
            String getNewsTag() {
                return "item";
            }

            @Override
            String getNewsPublishDateTag() {
                return "pubDate";
            }

            @Override
            String getChannelId() {
                return CHANNEL_ID;
            }
        };
    }

    @Override
    protected String getChannelResourceLink() {
        return RESOURCE;
    }
}
